package com.fengkai.filepost.pdfoutstream.test.ODsolutions;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * @author Fengkai
 * @creat 2023/4/12
 */
public class DataClassification {

    public static void main (String[] args) {
        System.out.println(getClassification("1 4 256 257 258 259 260 261 262 263 264 265"));
    }

    public static int getClassification (String input) {
        String[] s = input.split(" ");
        int c = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        int [] ints = new int[s.length - 2];
        for (int i = 2; i < s.length; i++) {
            ints[i - 2] = Integer.parseInt(s[i]);
        }
        //对c,b取模求和
        HashMap<Integer, Integer> result = new HashMap<>();
        for (int i = 0; i < ints.length; i++) {
            int sum  = 0;
            String s1 = Integer.toBinaryString(ints[i]);
            while (s1.length() > 8){
                String cache = s1.substring(s1.length() - 8);
                sum += Integer.parseInt(cache);
                s1 = s1.substring(0, s1.length() - 8);
            }
            sum += Integer.parseInt(s1);
            if (sum % b < c) {
                result.put(sum % c, result.getOrDefault(sum % c, 0) + 1);
            }
        }
        int i = 0;
        for (Map.Entry<Integer, Integer> integerIntegerEntry : result.entrySet()) {
            i = Math.max(i, integerIntegerEntry.getValue());
        }
        return i;
    }
}
